package com.atguigu.gulimall.order.web;

import com.atguigu.gulimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class HelloController {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @ResponseBody
    @GetMapping("/hello")
    public String create(){
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn("1234567890");
        orderEntity.setModifyTime(new Date());

        rabbitTemplate.convertAndSend("order.event.exchange","order.create.order",orderEntity);
        System.out.println("开始发送消息");
        return "create";
    }
    @GetMapping("/{page}.html")
    public String hello(@PathVariable String page){
        return page;
    }
}
